﻿using System.Web;
using System.Text;
using System.IO;
using System.Net;
using System;
using System.Collections.Generic;


namespace WeChatParking.Core.Payment.Alipay
{
    /// <summary>
    /// 类名：AlipayConfig
    /// 功能：基础配置类
    /// 详细：设置帐户有关信息及返回路径
    /// 如何获取安全校验码和合作身份者ID
    /// 1.用您的签约支付宝账号登录支付宝网站(www.alipay.com)
    /// 2.点击“商家服务”(https://b.alipay.com/order/myOrder.htm)
    /// 3.点击“查询合作者身份(PID)”、“查询安全校验码(Key)”
    /// </summary>
    public class AlipayConfig
    {
        #region 字段
        //private static string partner = "";
        //private static string seller_email = "";
        //private static string key = "";
        private static string input_charset = "";
        private static string sign_type = "";

        private static string direct_pay_service = "";
        private static string mobile_direct_pay_service = "";
        //private static string notify_url = "";
        //private static string return_url = "";
        //private static string error_notify_url = "";

        private static string gateway_url = "";
        private static string http_verify_url = "";


        #endregion

        static AlipayConfig()
        {

            ////合作身份者ID，以2088开头由16位纯数字组成的字符串
            //partner =ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayPartner);

            ////收款支付宝账号
            //seller_email =ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipaySellerEmail);

            ////交易安全检验码，由数字和字母组成的32位字符串
            //key = ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayKey);


            //字符编码格式 目前支持 gbk 或 utf-8
            input_charset = "utf-8";

            //签名方式，选择项：RSA、DSA、MD5
            sign_type = "MD5";

            direct_pay_service = "create_direct_pay_by_user";
            mobile_direct_pay_service = "alipay.wap.create.direct.pay.by.user";

            //notify_url = ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayNotifyUrl);
            //return_url = ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayReturnUrl);
            //error_notify_url = ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayErrorNotifyUrl);      

            gateway_url = "https://mapi.alipay.com/gateway.do?";
            http_verify_url = "https://mapi.alipay.com/gateway.do?service=notify_verify";
        }

        #region 属性
        /// <summary>
        /// 获取或设置合作者身份ID
        /// </summary>
        public static string Partner
        {
            get { return ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayPartner); }
            //set { partner = value; }
        }

        /// <summary>
        /// 获取或设置合作者身份ID
        /// </summary>
        public static string Seller_email
        {
            get { return ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipaySellerEmail); }
            //set { seller_email = value; }
        }

        /// <summary>
        /// 获取或设交易安全校验码
        /// </summary>
        public static string Key
        {
            get { return ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayKey); }
            //set { key = value; }
        }

        /// <summary>
        /// 获取字符编码格式
        /// </summary>
        public static string Input_charset
        {
            get { return input_charset; }
        }

        /// <summary>
        /// 获取签名方式
        /// </summary>
        public static string Sign_type
        {
            get { return sign_type; }
        }

        /// <summary>
        /// 即时到账服务名
        /// </summary>
        public static string DirectPayService
        {
            get { return direct_pay_service; }
            
        }

        /// <summary>
        /// 手机支付即时到账服务名
        /// </summary>
        public static string MobileDirectPayService
        {
            get { return mobile_direct_pay_service; }

        }

        /// <summary>
        /// 支付结果异步通知地址
        /// </summary>
        public static string NotifyUrl
        {
            get { return ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayNotifyUrl); }
           
        }

        /// <summary>
        /// 移动支付结果异步通知地址
        /// </summary>
        public static string MobileNotifyUrl
        {
            get { return ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayMobileNotifyUrl); }

        }


        /// <summary>
        /// 支付结果同步通知地址
        /// </summary>
        public static string ReturnUrl
        {
            get { return ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayReturnUrl); }
            
        }

        /// <summary>
        /// 出错异步通知地址
        /// </summary>
        public static string ErrorNotifyUrl
        {
            get { return ConfigHelper.GetConfig(ConfigHelper.ConfigItem.AlipayErrorNotifyUrl); }
           
        } 

         /// <summary>
        /// 支付宝网关地址
        /// </summary>
        public static string GateWayUrl
        {
            get { return gateway_url; }
            
        }

        /// <summary>
        /// 支付宝消息验证地址
        /// </summary>
        public static string HttpVerifyUrl
        {
            get { return http_verify_url; }
        }

        #endregion
    }
}